package shuiyuqing.views.adapters;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.xkh.xkh.R;

import java.util.ArrayList;

import com.xkh.xkh.MyApplication;
import shuiyuqing.model.BasicInfoModel;
import shuiyuqing.model.Type;
import shuiyuqing.network.beans.IrrBRStadia;

/**
 * 监测点
 * Created by 凯 on 2015/11/9.
 */
public class WatchPointAdapter extends BaseAdapter {

    // 所有的监测点
    ArrayList<IrrBRStadia> stadias;

    //

    public void setType(int type)
    {
        // 是水情站
        if (type == Type.WATER)
        {
            stadias = (ArrayList<IrrBRStadia>) BasicInfoModel.getWaterPoint();
        }
        // 是雨晴站
        else if (type == Type.RAIN)
        {
            stadias = (ArrayList<IrrBRStadia>) BasicInfoModel.getRainPoint();
        }
    }

    @Override
    public int getCount() {
        return stadias.size();
    }

    @Override
    public Object getItem(int position) {
        return stadias.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        IrrBRStadia stadia = stadias.get(position);

        convertView = View.inflate(MyApplication.share(), R.layout.item_sel_point,null);
        TextView tv_pointName = (TextView) convertView.findViewById(R.id.id_tv_pointName);
        tv_pointName.setText(stadia.getStadiaName());

        convertView.setTag(R.id.id_point,stadia);
        return convertView;
    }
}
